<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<script src="https://cdn.bootcdn.net/ajax/libs/dexie/3.0.4/dexie.min.js"></script>
	</head>

	<body>
		<script>
			// 基于indexedDB的数据库

			const db = new Dexie('MyDatabase');

			db.version(1).stores({
				friends: '++id, name, age',
			});

			db.friends.add({ name: 'lei', age: 25 });
			db.friends.add({ name: 'deng', age: 27 });

			// 查询年龄26的好友
			db.friends
				.where('age')
				.above(26)
				.toArray()
				.then(res => {
					console.log(res);
				});
		</script>
	</body>
</html>
